<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title></title>
</head>
<style type="text/css">
    *{
        margin: 0;
        padding: 0;
        overflow: hidden;
    }
    .content{
        width: 100%;
        height: 100vh;
        background-color: #4a374a;
    }
    .title{
        width: 100%;
        text-align: center;
        color: #fff;
        font-size: 36px;
        padding-top: 150px;
        padding-bottom: 100px;
    }
    .input{
        width: 100%;
        text-align: center;
    }
    .input input{
        background-color: #2d2d3f;
        border: 0;
        width: 150px;
        height: 25px;
        line-height: 25px;
        padding: 5px 20px;
        margin-top: 25px;
        border-radius: 5px;
        font-weight: bold;
        border-bottom: 1px solid #8888be;
    }
    .btn{
        width: 100%;
        text-align: center;
    }
    .btn button{
        margin-top: 50px;
        width: 190px;
        height: 30px;
        border-radius: 5px;
        background-color: #4a77d4;
        border: 0;
        color: #FFFFFF;
    }
</style>
<body>
<div class="content">
    <div class="title">用户登录</div>
    <div class="input">
        <input type="text" id="name" value="" placeholder="用户名" />
    </div>
    <div class="input">
        <input type="password" id="pass" value="" placeholder="密码" />
    </div>
    <div class="btn">
        <button onclick="submit()" type="button">登录</button>
    </div>
</div>
</body>
<script typet="text/javascript" src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">

    function submit(){
        let user_name = document.getElementById('name').value;
        let user_pass = document.getElementById('pass').value;
        if(user_name === '' || user_pass === ''){
            alert('不能为空')
        }else{
            $.ajax({
                data:{
                    name: user_name,
                    pass:user_pass
                },
                dataType: 'json',
                type:'post',
                url:'http://www.baidu.com',
                success: function(res){
                    console.log(res)
                },
                error: function (err){
                    console.log(err)
                }
            })
        }
    }
</script>
</html>

